#include <cstdlib>
#include <pthread.h>
#include <iostream>
#include <vector>
#include "client_thread.h"
#include "client_socket.h"
#define PORT 4321

using std::cout;
using std::endl;
using std::string;
using std::vector;

Client_thread::Client_thread(Client_socket* s){
    socket = s;
}

Client_thread::~Client_thread(){
}

void Client_thread::ejecutar(){
    while (*(this->running)){
        while (!this->keys->empty()) {                      
            string buffer = this->keys->front();
            int tam = buffer.size();
            this->socket->enviar(buffer, tam);
            this->keys->pop();
        }
    }
    this->socket->cerrar_conexion();
}

void Client_thread::setKeys(queue<string>* keys){
    this->keys = keys;
}

void Client_thread::setFlag(bool* running){
    this->running = running;
}
